package com.example.project.service.impl;

import com.example.project.mapper.UserMapper;
import com.example.project.pojo.User;
import com.example.project.service.UserService;
import com.example.project.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User findbyusername(String username) {
      User u= userMapper.findbyusername(username);

        return u;
    }

    @Override
    public void register(String username, String password, String name) {

        userMapper.add(username,password,name);

    }



    @Override
    public void updatePwd(String newpwd) {
           Map<String,Object> map= ThreadLocalUtil.get();
           Integer id=(Integer) map.get("id");
           userMapper.updatePwd(newpwd,id);
    }
}
